package com.eos.business.service;

import java.util.List;
import java.util.Map;

import com.eos.common.tool.DaoAccessObjectPoolContextFactory;
import com.eos.orm.c3p0.dao.AbstractC3p0Dao;
import com.eos.orm.c3p0.dao.impl.BrokerageTempDetailDaoImpl;
import com.eos.orm.c3p0.dao.impl.ViewBrokerageCheckedReportDaoImpl;
import com.eos.orm.c3p0.dao.impl.ViewBrokerageReportDaoImpl;
import com.eos.orm.mybatis.model.BrokerageTempDetail;
import com.eos.orm.mybatis.model.ViewBrokerageReport;
import com.eos.orm.mybatis.model.ViewCheckedBrokerageReport;
import com.hf.utils.PaginationBean;

public class SysCommissionBusinessService  extends AbstractEosService<BrokerageTempDetail>{
	private AbstractC3p0Dao<BrokerageTempDetail> brokerageTempDetailDao = (BrokerageTempDetailDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("BrokerageTempDetailDao");
	private AbstractC3p0Dao<ViewBrokerageReport> viewBrokerageReportDao = (ViewBrokerageReportDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ViewBrokerageReportDao");
	
	private AbstractC3p0Dao<ViewCheckedBrokerageReport> viewCheckedBrokerageReportDao = (ViewBrokerageCheckedReportDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ViewBrokerageCheckedReportDao");
	
	/**
	 * 批量保存线下佣金明细
	 * @param bdtList
	 * @return
	 */
	public String batchSaveBorkerageTemp(List<BrokerageTempDetail> bdtList){
		boolean flag = brokerageTempDetailDao.save(bdtList);
		return flag ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 分页查询临时佣金明细
	 * @param map
	 * @return
	 */
	public PaginationBean getBrokerageTempDetailList(Map<String, String> map){
		PaginationBean pb = brokerageTempDetailDao.findBean(map);
		List<BrokerageTempDetail> list = brokerageTempDetailDao.findPage(map);
		pb.setResultList(list);
		return pb;
	}
	
	/**
	 * 分页查询佣金汇总
	 * @param map
	 * @return
	 */
	public PaginationBean getCommissionReportList(Map<String, String> map){
		PaginationBean pb = viewBrokerageReportDao.findBean(map);
		List<ViewBrokerageReport> list = viewBrokerageReportDao.findPage(map);
		pb.setResultList(list);
		return pb;
	}
	
	/**
	 * 获取已核对后的佣金汇总(含: 结算客户佣金, 易道佣金, 差额=易道佣金-结算客户佣金)
	 * @param map
	 * @return
	 */
	public PaginationBean getCheckedCommissionReportList(Map<String, String> map){
		PaginationBean pb = viewCheckedBrokerageReportDao.findBean(map);
		List<ViewCheckedBrokerageReport> list = viewCheckedBrokerageReportDao.findPage(map);
		if(pb != null)
			pb.setResultList(list);
		return pb;
	}
}

